<?php
/**
 * 活动UI
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-03-28
 * Time: 下午 11:26
 */
namespace App;

use Model\ActivityUiMod;
use Pub\cache\Cache;

class ActivityUi extends Action
{
    private $ActivityUi = null;

	public function __construct()
	{
		parent::__construct();
		$this->ActivityUi = new ActivityUiMod();
	}

    /**
     * 设置UI
     * @params activity_id 活动id
     * @param data 数据
     */
    public function set()
    {
        Cache::remove(Cache::ACTIVITY_INFO,array("activity_id"=>$this->_gpc["data"]["activity_id"]));
        $_ui = $this->ActivityUi->findOne(array("activity_id"=>$this->_gpc["data"]["activity_id"]),array("id"));
        if($_ui){
            $_result = $this->ActivityUi->update($this->_gpc["data"],array("id"=>$_ui["id"]));
        }else{
            $_result = $this->ActivityUi->insert($this->_gpc["data"]);
        }
        if($_result) $this->_result = array("status"=>"success");
        $this->result($this->_result);
    }

    /**
     * 获取活动UI
     * @param activity_id 活动id
     */
    public function get()
    {
        $_ui = $this->ActivityUi->findOne(array("activity_id"=>$this->_gpc["activity_id"]),array("skin"));
        if($_ui){
            $this->_result = array("status"=>"success","data"=>$_ui);
        }
        $this->result($this->_result);
    }
}